package xyz.xtt.equity.service;

import java.util.List;
import java.util.Map;

import xyz.xtt.equity.api.dto.TblBenefitPackageDto;
import xyz.xtt.equity.api.dto.TblUserBenefitByAssetIdDto;
import xyz.xtt.equity.api.enums.UserBenefitSourceTypeEnum;
import xyz.xtt.equity.client.request.TblUserBenefitDto;
import xyz.xtt.equity.entity.TblBenefitPackage;

/**
 * @author dale
 * @date 2025/2/11
 **/
public interface IBenefitService {
	/**
	 * 查询用户权益数据
	 *
	 * @param appUserId    用户id
	 * @param benefitCodes 多个benefitCode逗号分隔
	 * @return
	 */
	Map<String, Integer> getUserBenefits(long appUserId, String benefitCodes);

	/**
	 * 用户权益消耗
	 *
	 * @param appUserId         用户id
	 * @param benefitCode       权益code
	 * @param consumeNum        消耗数量
	 * @param operateBusinessId 操作业务id。可空。比如铸造消耗权益时传铸造审核记录id
	 * @param operateDesc       操作描述。比如铸造消耗权益时传：铸造审核或更具体信息
	 * @return
	 */
	boolean userBenefitConsumed(long appUserId, String benefitCode, int consumeNum, Long operateBusinessId, String operateDesc);

	/**
	 * 用户权益消耗
	 *
	 * @param appUserId         用户id
	 * @param benefitCode       权益code
	 * @param consumeNum        消耗数量
	 * @param operateBusinessId 操作业务id。可空。比如铸造消耗权益时传铸造审核记录id
	 * @param operateDesc       操作描述。比如铸造消耗权益时传：铸造审核或更具体信息
	 * @return 返回实际消耗次数
	 */
	int userBenefitConsumeAsMuchAsPossible(long appUserId, String benefitCode, int consumeNum, Long operateBusinessId, String operateDesc);

	/**
	 * 恢复已消耗用户权益
	 * 
	 * @param appUserId         用户id
	 * @param operateBusinessId 操作业务id。可空。比如铸造审核不通过时恢复权益时传铸造审核记录id
	 * @param operateDesc       操作描述。可空。比如铸造审核不通过恢复权益时传：铸造审核不通过或更具体信息
	 */
	void userBenefitRecover(long appUserId, Long operateBusinessId, String operateDesc);

	/**
	 * 获取3日内VIP将要过期的用户id集合
	 *
	 * @param pageNo      页码
	 * @param pageSize    每页数量
	 * @param benefitCode 权益code
	 * @return
	 */
	List<TblUserBenefitDto> getExpiringUserBenefits(int pageNo, int pageSize, String benefitCode);

	/**
	 * 权益发放接口
	 * 
	 * @param packageCode    权益包代码
	 * @param appUserId      下发目标用户id
	 * @param sendNum        发放数量
	 * @param sourceTypeEnum 权益来源
	 * @param sourceRefId    权益来源关联业务id
	 */
	void sendBenefitPackage(String packageCode, long appUserId, int sendNum, UserBenefitSourceTypeEnum sourceTypeEnum, Long sourceRefId,
			Long benefitPurchaseRecord);

	/**
	 * 权益发放同时记录权益领取记录
	 * 
	 * @param packageCode
	 * @param appUserId
	 * @param sendNum
	 * @param sourceTypeEnum
	 * @param sourceRefId
	 */
	void recordAndSendFreeBenefitPackage(String packageCode, long appUserId, int sendNum, UserBenefitSourceTypeEnum sourceTypeEnum, Long sourceRefId);

	void sendBenefitPackage(TblBenefitPackage benefitPackage, long appUserId, int sendNum, UserBenefitSourceTypeEnum sourceTypeEnum, Long sourceRefId,
			Long benefitPurchaseRecord);

	void sendAssetNoBenefit(Long assetId, List<Long> assetNodIds, Long senderId, Long receiverId);

	List<TblBenefitPackageDto> getPackageByIds(List<Long> packageIds);

	/**
	 * 冻结资产权益
	 * 
	 * @param assetNodIds
	 */
	Boolean blockAssetNoBenefit(List<Long> assetNodIds, Long userId);

	/**
	 * 资产权益解冻
	 * 
	 * @param assNoIds
	 */
	Boolean unBlockAssetNoBenefit(List<Long> assNoIds, Long userId);

	TblUserBenefitByAssetIdDto getBenefitDetailInfo(String uid, String assetId);

}
